package com.viknix.threadpool.manager.config.dump;

import com.viknix.threadpool.manager.cluster.core.ServerMemberManager;
import com.viknix.threadpool.manager.config.dump.condition.ConditionOnExternalStorage;
import com.viknix.threadpool.manager.config.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @Author: Dongqi
 * @Date: 2021/11/18 17:38
 * @Version 1.0
 * @Description: 集群模式下会启动 TODO
 */
@Slf4j
@Conditional(ConditionOnExternalStorage.class)
@Component
public class ExternalDumpService extends DumpService {

    @PostConstruct
    void init() {
        log.info(">>> {}执行。", this.toString());
    }

    /**
     * Here you inject the dependent objects constructively, ensuring that some of the dependent functionality is
     * initialized ahead of time.
     *
     * @param memberManager {@link ServerMemberManager}
     */
    public ExternalDumpService(ConfigService configService, ServerMemberManager memberManager) {
        super(configService, memberManager);
    }

    @Override
    protected boolean canExecute() {
        return memberManager.isFirstIp();
    }
}
